layui.use(['jquery','common','layer','form','larryMenu'],function(){
    var $ = layui.$,
        layer = layui.layer,
        form = layui.form,
        common = layui.common;
    // 页面上下文菜单
    var larryMenu = layui.larryMenu();

    var mar_top = ($(document).height()-$('#larry_login').height())/2.5;
    $('#larry_login').css({'margin-top':mar_top});
    //common.larryCmsSuccess('用户名：larry 密码：larry 无须输入验证码，输入正确后直接登录后台!','larryMS后台帐号登录提示',20);
    var placeholder = '';
    $("#larry_form input[type='text'],#larry_form input[type='password']").on('focus',function(){
          placeholder = $(this).attr('placeholder');
          $(this).attr('placeholder','');
    });
    $("#larry_form input[type='text'],#larry_form input[type='password']").on('blur',function(){
          $(this).attr('placeholder',placeholder);
    });
    
    common.larryCmsLoadJq('/LarryMS/common/plus/jquery.supersized.min.js', function() {
        $.supersized({
            // 功能
            slide_interval: 3000,
            transition: 1,
            transition_speed: 1000,
            performance: 1,
            // 大小和位置
            min_width: 0,
            min_height: 0,
            vertical_center: 1,
            horizontal_center: 1,
            fit_always: 0,
            fit_portrait: 1,
            fit_landscape: 0,
            // 组件
            slide_links: 'blank',
            slides: [{
                image: '/LarryMS/backstage/images/login/1.jpg'
            }, {
                image: '/LarryMS/backstage/images/login/2.jpg'
            }, {
                image: '/LarryMS/backstage/images/login/3.jpg'
            }]
        });
    });

    form.on('submit(submit)',function(data){
    		$.post("/login/loginClick",{"userName":data.field.user_name,"password":data.field.password},function(result){
    			if(result.status == 200){
    				layer.msg('登入成功', {
    					icon: 1,
    					time: 2000 //2秒关闭（如果不配置，默认是3秒）
    				}, function(){
    					window.location.href = '/index';
    				});
    			} else {
    				common.larryCmsError(result.msg,common.larryCore.tit);
    			}
    		});        
        return false;
    });
    
//    $('#change').on('click',function(){
//    		var codeimage = document.getElementById('codeimage');
//    		codeimage.src = "/login/verifyCode?t"+Math.random();
//    });
//    $('#codeimage').on('click',function(){
//		var codeimage = document.getElementById('codeimage');
//		codeimage.src = "/login/verifyCode?t"+Math.random();
//    });

    // 右键菜单控制
    var larrycmsMenuData = [
        [{
            text: "刷新页面",
            func: function() {
                top.document.location.reload();
            }
        }, {
            text: "检查元素(F12)",
            func: function() {
                common.larryCmsError('抱歉！暂不支持此功能，可联系开发者',common.larryCore.tit);
            }
        }],
        [{
            text: "访问开发者官网",
            func: function() {
                window.open('https://www.sundablog.com');
            }
        },{
            text: "给开发者店长",
            func: function() {
                window.open('https://www.sundablog.com');
            }
        }]
    ];
    larryMenu.ContentMenu(larrycmsMenuData,{
         name: "html" 
    },$('html'));
});
    